package com.huawei.ec.ttt.dao.impl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation; 
import com.huawei.ec.ttt.dao.UserDao;
import com.huawei.ec.ttt.model.User;

@Repository("userDAO")
/* 
 * readOnly表示事务是否只读的，不能进行插入更新操作 
 * propagation = Propagation.REQUIRED表示执行这个类实例方法需开启事务 
 * rollbackFor = Throwable.class表示遇到Throwable类及子类（即发生了异常）时事务进行回滚操作 
 */  
@Transactional(readOnly=false , propagation = Propagation.REQUIRED , rollbackFor = Throwable.class) 
public class UserDaoImpl extends SqlMapClientDaoSupport implements UserDao {

	
	public UserDaoImpl() {
		super();
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<User> getUserList() {
		return (List<User>) getSqlMapClientTemplate().queryForList("user.getUserList");
	}

	@Override
	public void addUser(User user) {
		getSqlMapClientTemplate().insert("user.addUser", user);
	}
}
